import http from '@/base/http';

/**
 * 需求管理
 */
enum DEMAND_API {
  DEMAND_LIST = '/wx/demand/wxHomePage', // 需求列表
  ALL_DEMAND_POST_TYPE = '/wx/demand/post-type',
  DEMAND_POST_TYPE = '/wx/user/follow/getUserFollowPostTypes',
  DEMAND_POST_TYPE_ALL = '/wx/user/follow/getUserFollowPostTypesNew',
  SET_DEMAND_POST_TYPE = '/wx/user/follow/setUserFollowPostTypes',
  DEMAND_DETAIL = '/wx/demand/getById', // 需求详情
  DEMAND_CREATE = '/wx/demand/create', // 发布需求
  DEMAND_UPDATE = '/wx/demand/update', // 更新需求
  DEMAND_OPRATE = '/wx/demand/interact/operate', // 需求操作（点赞、点踩）
  DEMAND_CANCEL = '/wx/demand/interact/cancel', // 需求操作取消（取消点赞、取消点踩）
  DEMAND_COLLECT = '/wx/demand/collection/operate', // 需求操作（收藏）
  DEMAND_COLLECT_CANCEL = '/wx/demand/collection/cancel', // 需求操作取消（取消收藏）
  DEMAND_PUBLISH_LIMIT_CHECK = '/wx/demand/publish-limit', // 发布需求限制检查
}

/**
 * 需求列表
 */
export function fetchDemandList(data: unknown): Promise<any> {
  return http.get(DEMAND_API.DEMAND_LIST, data);
}

/**
 * 需求列表
 */
export function fetchAllDemandPostType(data: unknown): Promise<any> {
  return http.get(DEMAND_API.ALL_DEMAND_POST_TYPE, data);
}

/**
 * 需求列表
 */
export function fetchDemandPostType(data: unknown): Promise<any> {
  return http.get(DEMAND_API.DEMAND_POST_TYPE, data);
}

/**
 * 需求列表
 */
export function fetchDemandPostTypeAll(data: unknown): Promise<any> {
  return http.get(DEMAND_API.DEMAND_POST_TYPE_ALL, data);
}

export function fetchPUBLISH_LIMIT(data: unknown): Promise<any> {
  return http.get(DEMAND_API.DEMAND_PUBLISH_LIMIT_CHECK, data);
}

/**
 * 收藏
 */
export function setEmandPostType(data: unknown): Promise<any> {
  console.log(data, 'setEmandPostType data')
  return http.post(DEMAND_API.SET_DEMAND_POST_TYPE, data);
}

/**
 * 需求详情
 */
export function fetchDemandDetail(data: unknown): Promise<any> {
  return http.get(DEMAND_API.DEMAND_DETAIL, data);
}

/**
 * 发布需求
 */
export function createDemand(data: unknown): Promise<any> {
  return http.post(DEMAND_API.DEMAND_CREATE, data);
}

/**
 * 需求操作（点赞、点踩）
 */
export function operateDemand(data: unknown): Promise<any> {
  return http.post(DEMAND_API.DEMAND_OPRATE, data);
}

/**
 * 需求操作取消（取消点赞、取消点踩）
 */
export function cancelOperateDemand(data: unknown): Promise<any> {
  return http.put(DEMAND_API.DEMAND_CANCEL, data);
}

/**
 * 需求操作取消（取消点赞、取消点踩）
 */
export function updateDemand(data: unknown): Promise<any> {
  return http.put(DEMAND_API.DEMAND_UPDATE, data);
}

/**
 * 收藏
 */
export function operateCollect(data: unknown): Promise<any> {
  return http.post(DEMAND_API.DEMAND_COLLECT, data);
}

/**
 * 取消收藏
 */
export function operateCancelCollect(data: unknown): Promise<any> {
  return http.put(DEMAND_API.DEMAND_COLLECT_CANCEL, data);
}
